# -*- coding: utf-8 -*-
"""
Created on Sun Jun 10 13:36:15 2012

@author: nzhao
"""

from traits.api import HasTraits, Str, Button, Instance, List
from traitsui.api import View, Group, Item

from math_qm.CoordianteSystem import CoordinateSystem
from phy.spin.MultiSpin import MultiSpin

log_text_group = Group(Item('log_text', height = 0.8, show_label = False, style = 'custom'),
                       Item('bt'),
                       label = 'Log Text',
                       show_border = True
                       )
                       
class LogText(HasTraits):
    log_text   = Str
    bt         = Button
    multi_spin = Instance(MultiSpin)
    axes_list  = List(CoordinateSystem)

    def __init__(self):
        pass
    
    def set_instance(self, multi_spin = None, axes = None):
        self.multi_spin = multi_spin
        self.axes_list  = axes
        
    def _bt_fired(self):
        self.log_text = str(len(self.multi_spin.spin_list)) +"\t"
        self.log_text = self.log_text + str(self.axes_list[0].x_axis) +"\t"      \
                        + '\n'

    view = View(
                log_text_group,
               
                width = 0.8,
                height = 0.9,
                resizable = True,
                kind='live'
                )    
            
if __name__ == '__main__':
    log = LogText()
    log.configure_traits()